USE [BD_SYS_ATENCIONES]
GO
/****** Object:  StoredProcedure [dbo].[GRMaeRequerimiento_Aprobar]    Script Date: 02/14/2014 11:41:13 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create Procedure [dbo].[GRMaeRequerimiento_Atender](
   @iNumReq       int,
   @iCodUsuA      int,
   @vNomTer       varchar(20),
   @iCodUOr       int,
   @vObsMov       varchar(500),
   @iCodUsu       int,
   @dtFecMov      datetime
)
As

   Declare @dtFecAct datetime
   
   Set @dtFecAct = GETDATE()

Begin
   
   Update GRMaeRequerimiento
   Set iCodEstReq = 4, --Atendido
       iCodUsuA = @iCodUsuA, 
       vNomTer = @vNomTer, 
       dtFecAct = @dtFecAct       
   Where iNumReq = @iNumReq 
   
End

begin

  Insert into GRMovRequerimiento 
   (iCodUOr, iCodUsu, iNumReq, iCodEstReq, dtFecMov, vObsMov, iCodUsuA, vNomTer, dtFecAct)
  Values
   (@iCodUOr, @iCodUsu, @iNumReq, 4, @dtFecMov, @vObsMov, @iCodUsuA, @vNomTer, @dtFecAct)
end